package edu.scau.ojforwarder.controller;

import edu.scau.ojforwarder.bean.NowcoderStatus;
import edu.scau.ojforwarder.bean.NowcoderSubmission;
import edu.scau.ojforwarder.bean.BaseResult;
import edu.scau.ojforwarder.service.NowcoderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nowcoder")
public class NowcoderController {

    @Autowired
    private NowcoderService nowcoderService;

    @RequestMapping(value = "/submit", method = RequestMethod.POST)
    public BaseResult<NowcoderStatus> submit(@RequestBody NowcoderSubmission submission) {
        return nowcoderService.addSubmission(submission);
    }

    @RequestMapping(value = "/status/{submissionId}", method = RequestMethod.GET)
    public BaseResult<NowcoderStatus> getStatus(@PathVariable String submissionId) {
        return nowcoderService.getStatus(submissionId);
    }


    @RequestMapping(value = "/problem-desc", method = RequestMethod.GET)
    public BaseResult<String> problemDesc(@RequestParam("cid") String contestId,
                                          @RequestParam("pid") String problemNum) {
            return nowcoderService.getProblemDesc(contestId, problemNum);
    }
}
